Skip to content

Conversation

@alexander-alderman-webb
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb commented Nov 18, 2025

Description

Create spans for SQL rollbacks issued when Django calls rollback() on a PEP-249 database connection.

Patch the BaseDatabaseWrapper._rollback method, the same method in which debug statements were added in django/django@798e38c.

Rollback spans are generated for transaction.atomic blocks and for manual transaction.rollback() calls when auto-commit is disabled. Tests cover both cases, for SQLite and PostgreSQL, respectively.

Screenshot 2025-11-21 at 11 12 23

Trying for yourself

Refer to #5100 (comment).

Issues

Reminders

@alexander-alderman-webb alexander-alderman-webb changed the title feat(django): Instrument database commits feat(django): Instrument database rollbacks Nov 18, 2025
@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.23%. Comparing base (e068db6) to head (947ac41).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5115      +/-   ##
==========================================
- Coverage   83.95%   80.23%   -3.72%     
==========================================
  Files         180      180              
  Lines       18212    18222      +10     
  Branches     3234     3235       +1     
==========================================
- Hits        15289    14620     -669     
- Misses       1931     2695     +764     
+ Partials      992      907      -85     
Files with missing lines Coverage Δ
sentry_sdk/consts.py 99.41% <100.00%> (+<0.01%) ⬆️
sentry_sdk/integrations/django/__init__.py 85.20% <100.00%> (+0.34%) ⬆️

... and 20 files with indirect coverage changes

@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review November 21, 2025 10:27
@alexander-alderman-webb alexander-alderman-webb requested a review from a team as a code owner November 21, 2025 10:27
@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review November 24, 2025 13:34
Base automatically changed from webb/django-sql-commit to master November 25, 2025 08:10
@alexander-alderman-webb alexander-alderman-webb merged commit 5de66e2 into master Nov 25, 2025
144 of 146 checks passed
@alexander-alderman-webb alexander-alderman-webb deleted the webb/django-sql-rollback branch November 25, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants